<!--
  To change this template, choose Tools | Templates
  and open the template in the editor.
-->

<%@ page contentType="text/html;charset=UTF-8" %>

<html>
  <head>
    <meta name="layout" content="mobile">
    <title>${forum.topic}</title>
  </head>
  <body>
    <h1>Forum For ${facility.name}</h1>
    <h2>${forum.topic}</h2>
    <g:each var="post" in="${forum.posts.sort{it.dateCreated}}">
      <table>
        <tr>
          <td>${post.message}</td>
          <td style="padding-left: 15px">${post.dateCreated}</td>       
          <td style="padding-left: 15px">By: ${post.user.username}</td>
          <sec:ifAnyGranted roles="ROLE_MODERATOR, ROLE_OWNER">
            <td style="padding-left: 15px">
              <g:form action="deletePost">
                <g:hiddenField name="facilityName" value="${facility.name}"/>
                <g:hiddenField name="topic" value="${forum.topic}"/>
                <g:hiddenField name="postId" value="${post.id}"/>
                <g:submitButton name="button" data-icon="delete" data-iconpos="notext"/>
              </g:form>
            </td>
          </sec:ifAnyGranted>
        </tr>
        </br>
      </table>
    </g:each>
    <g:form action="view">
      <g:hiddenField name="facility.name" value="${facility?.name}"/>
      <g:hiddenField name="topic" value="${forum.topic}"/>
      <g:textArea id="attributeDescription" name="message" width="1000px" height="1000px"/>
      <g:submitButton name="addPost" value="Add Post"/>
    </g:form>
    <g:form controller="facility" action="view">
      <g:hiddenField name="name" value="${facility.name}"/>
      <g:submitButton name="back" value="Facility" data-icon="back"/>
    </g:form>
  </body>
</html>
